package load.parent;

import core.ConnectException;
import core.OutPort;
import core.StdNode;

/**
 *
 * @author Wijnand
 */
public class Store<T> extends StdNode{

    protected T _value;
    protected OutPort value;

    public Store(T x) {
        _value = x;
        value = new OutPort(_value.getClass()){;//, valueChanged) {	// T.class geeft fout

            @Override
            protected Object getValueInternal() {
                return _value;
            }
        };
        this.putPort("value", this.value);
    }

    public void setValue(T x) throws ConnectException {
        this._value = (T) x;
    }

    public void setType(T x) throws ConnectException {
        this.setValue(x);
        value = new OutPort(_value.getClass()){	// T.class geeft fout

            @Override
            protected Object getValueInternal() {
                return _value;
            }
        };
        ports.put("value", value);
    }

    /**
     * @return the _value
     */
    public T getValue() {
        return _value;
    }
}